package com.yusvn.scm.goods.base.controller;

import com.alibaba.fastjson.JSONObject;
import com.jfinal.aop.Inject;
import com.jfinal.ext.cors.EnableCORS;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.yusvn.scm.common.BaseController;
import com.yusvn.scm.common.kit.RetKit;
import com.yusvn.scm.common.model.ScmPzmx;
import com.yusvn.scm.goods.base.service.ScmPzmxService;

/**
 * SCM 基础设置- 配置调拨明细
 * @author liugz
 *
 */
@EnableCORS
public class ScmPzmxController extends BaseController {

	@Inject
	ScmPzmxService srv;
	
	public void index() {
		renderJson();
	}

	public void page() {
		Kv kv = jsonStrToKv(getRawData()); //优先Request Payload的传值
		if(kv.isEmpty()) {
			kv = getKv();
		}
		
		Page<ScmPzmx> list = srv.page(kv);
		
		renderJson(RetKit.ok().setCount(list.getTotalRow()).setData( JSONObject.toJSON(list.getList()) ) );
	}
	
	public void add() {
		renderJson(srv.add(getRawData()));
	}

	public void update() {
        renderJson(srv.update(getRawData()));
	}

	public void remove() {
		renderJson(srv.remove(getPara("id")));
	}

	public void removeBatch() {		
		renderJson(srv.removeBatch(getRawData() ) );
	}
	
	
}
